<div class="list-group" id="respond">
	<h4 class="list-group-item">发表评论</h4>
<if condition="!is_login()">
<if condition="!$can_guest_comment">
<p class="list-group-item">要发表评论，您必须先<a href="{:U('User/login')}">登录</a>。</p>
<else />
<div id="commentform" class="form-horizontal list-group-item">
<div id="comment-user">
<p class="logged-in-help">游客
 <a href="{:U('User/login')}" title="登出这个帐号">登录</a></p>
</div>
<div class="markeditor ">
<textarea class="form-control autosize" rows="3"  id="commentcontent"></textarea>
</div>
<div id="comment-action" class="btn-toolbar clearfix">

<div class="btn-group">
<button class="btn btn-default"  id="submit-comment" data-url="{:tox_addons_url('LocalComment/Index/addComment', array('app'=>$app,'con'=>$mod, 'row_id'=>$row_id,'uid'=>$uid))}">
发表评论</button>
</div>
</div>

<input type="hidden" name="pid" id="pid" value="" />
</div>




</if>
<else />

<div id="commentform" class="form-horizontal list-group-item">
<div id="comment-user">
<p class="logged-in-help">以<a href="{$loginuser['space_url']}">{$loginuser['nickname']}</a>登录。
 <a href="{:U('User/logout')}" title="登出这个帐号">登出 »</a></p>
</div>
<div class="markeditor ">
<textarea class="form-control autosize" rows="3"  id="commentcontent"></textarea>
</div>
<div id="comment-action" class="btn-toolbar clearfix">

<div class="btn-group">
<button class="btn btn-default"  id="submit-comment" data-url="{:tox_addons_url('LocalComment/Index/addComment', array('app'=>$app,'con'=>$mod, 'row_id'=>$row_id,'uid'=>$uid))}">
发表评论</button>
</div>
</div>

<input type="hidden" name="pid" id="pid" value="" />
</div>

</if>
</div>
<ul class="list-group commentlist">
<li class="list-group-item respond-title">{$total_count}条回应给“{$info.title}”的评论</li>
<ul id="thread-comments">
<if condition="!$list">

<else />
 <volist name="list" id="comment">
<li class="comment byuser depth-1 list-group-item top parent">
<div class="comment-votes vote-group">
<a  callback="dingcai" href="{:tox_addons_url('LocalComment/Index/ding',array('id'=>$comment['id']))}" target=AjaxTodo class="up">
<span class="glyphicon glyphicon-chevron-up"></span> 
<span class="votes" id="commentding{$comment['id']}">{$comment['ding']}</span>
</a>
<a  callback="dingcai" href="{:tox_addons_url('LocalComment/Index/cai',array('id'=>$comment['id']))}" target=AjaxTodo class="down">
<span class="votes" style="margin:0;" id="commentcai{$comment['id']}">{$comment['cai']}</span>
<span class="glyphicon glyphicon-chevron-down"></span>

</a>
</div>	

 <eq name="comment.uid" value="0">
 <a id="comment-author" href="javascript:void(0)">
<img src="{:getRootUrl()}Addons/Avatar/default_64_64.jpg" class="avatar" width="50" height="50" style="display: block;">
</a>
<else/>
<a id="comment-author" href="{$comment.user.space_url}">
<img src="{$comment.user.avatar64}" class="avatar" width="50" height="50" style="display: block;">
</a>
</eq>

<div id="comment-body">
		<cite class="fn">
		<eq name="comment.uid" value="0">
                                <a>游客</a>
        <else/>
        <a href="{$comment.user.space_url}">{$comment.user.nickname|op_t}</a> 
        </eq>
        </cite>		
		
		
		<div id="comment-content"><p>{$comment.content|op_h}
		<if condition="$comment['pid'] gt 0">
		<span class="commentpre">{$comment.id|getpcomment}</span>
		</if></p></div>
		<div id="comment-meta">
			<time datetime="{$comment.create_time|toDate}" title="{$comment.create_time|toDate}">{$comment.create_time|toDate}</time>
			
			<if condition="is_login()" >
			<a class="comment-reply-link local-comment-reply" data-id="{$comment.id}" href="javascript:void(0)" data-uid="{$comment.uid}" data-username="{$comment.user.nickname|op_t}">
			<span class="glyphicon glyphicon-transfer"></span>回复</a>	
			<a class="pm" href="{:U('Ucenter/usersendmail',array('uid'=>$comment['uid']))}" title="私信" target="_blank"><span class="glyphicon glyphicon-share-alt"></span>私信</a>	
		
			<else />
			<a rel="nofollow" class="comment-reply-login" href="{:U('User/login')}" >
			<span class="glyphicon glyphicon-transfer"></span>登录以回复</a>
			</if>
</div>
</div>
</li>

</volist>
</if>
<div class="pull-right">
{:getPagination($total_count, $count)}
</div>
	</ul>

	</ul>
<script>
  
        $(function () {

$('.pagination li a').each(function(){

var href=$(this).attr('href');


$(this).attr('href',href+'#comments');


	
});


        	
        $('.local-comment-reply').click(function(e){
                 var $textarea = $('#commentcontent');
                 var nickname = $(this).attr('data-username');
                 var uid = $(this).attr('data-uid');
                 $textarea.focus();
                 $textarea.append('回复 @' + nickname + ' ：');
                 //tinyMCE.editors[0].setContent('');
                 //tinyMCE.editors[0].setContent('回复 @' + nickname + ' ：');//0表示当前的第一个编辑器
                // $textarea.val('回复 @' + nickname + ' ：');
                 $('#pid').val($(this).attr('data-id'));

                 
        });
        $('#submit-comment').click(function (e) {
            e.preventDefault();
            var url = $(this).attr('data-url');
            var pid=$('#pid').val();
           // tinyMCE.triggerSave();
            var content = $('#commentcontent').val();
            var $this = $(this);
            $this.attr('disabled','true');
            $.post(url, {content: content,pid:pid}, function (a) {
            	if(a.status){
            		layer.statusinfo(a.info,'success',function(){location.reload();});
            	}else{

            		$this.removeAttr('disabled');
            		layer.statusinfo(a.info,'error');
            	}
            });
        });
    });
</script>

